<template>
    <div class="container" :class="{'none': !props.show}">
        <div class="dialog-main">
            <div class="title">{{ props.title }}</div>
            <div class="control">
                <div class="btn-box danger" @click="emitConfirm">确定</div>
                <div class="btn-box success" @click="emitCancel">取消</div>
            </div>
        </div>
        <div class="v-modal"></div>
    </div>
</template>

<script setup lang="ts">
const props = defineProps({
    show: Boolean,
    title: {
        type: String,
        default: '是否退出？'
    }
});
const emit = defineEmits(['confirm', 'cancel']);
function emitConfirm() {
    emit('confirm');
}
function emitCancel() {
    emit('cancel');
}
</script>

<style scoped lang="scss">
.container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dialog-main {
    position: relative;
    width: 280px;

    background-color: #ffffff;
    border-radius: 5px;
    z-index: 50;
    padding: 20px;
    cursor: pointer;

    .title {
        text-align: center;
        margin-bottom: 30px;
    }

    .control {
        display: flex;
        justify-content: space-between;

        .btn-box {
            width: 96px;
            height: 40px;
            font-size: 12px;
            padding: 12px 20px;
            font-size: 14px;
            border-radius: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .success {
            color: #fff;
            background-color: #409eff;
            border-color: #409eff;
        }

        .danger {
            color: #fff;
            background-color: #f56c6c;
            border-color: #f56c6c;
        }
    }
}

.v-modal {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    opacity: .5;
    background: #000;
}

.none {
    display: none;
}
</style>
